import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('user', () => {
  const userId = ref(null)
  const role = ref(null)
  const username = ref(null)

  // 设置用户信息
  const setUserInfo = (userData) => {
    userId.value = userData.id
    role.value = userData.role
    username.value = userData.userName
  }

  // 清除用户信息
  const clearUserInfo = () => {
    userId.value = null
    role.value = null
    username.value = null
  }

  return { userId, role, username, setUserInfo, clearUserInfo }
})